import Vue from 'vue'

const isObject = function(val) {
	return typeof val == 'object' && Object.prototype.toString.call(val) == '[object Object]';
};
const isFunction = function(o) {
	return Object.prototype.toString.call(o) == '[object Function]';
};

const loginInfo = Vue.observable({
	key: '',
	userList: [],
	currentUser: {
		autoInfo: null,
		baseId: 0,
		cardInfo: null,
		className: '',
		classType: 0,
		email: '',
		feeId: 0,
		feeInfo: null,
		funcList: [],
		linkTel: '',
		mainId: 0,
		menuList: [],
		payInfo: null,
		photo: '',
		schoolId: 0,
		schoolName: '',
		schoolSets: '',
		smsTel: '',
		teacherFn: [],
		uiAccount: '',
		uiId: 0,
		uiName: '',
		uiStatus: 0,
		uiType: -1,
		uiTypeStr: ''
	},
	update: function(data) {
		var _this = this;
		if (!isObject(data)) return;
		Object.keys(data).forEach(function(key) {
			if (_this.hasOwnProperty(key)) {
				if (!isFunction(_this[key])) _this[key] = data[key];
			} else {
				_this.$set(key, data[key]);
			}
		});
	}
});
module.exports = {
	loginInfo
};
